Skip to content

fix: ship baseline builds for x64 CPUs without AVX2#97

Open
jamie-at-bunny wants to merge 2 commits into
mainfrom
fix/baseline-build-for-older-cpus
Open

fix: ship baseline builds for x64 CPUs without AVX2#97
jamie-at-bunny wants to merge 2 commits into
mainfrom
fix/baseline-build-for-older-cpus

Conversation

@jamie-at-bunny

@jamie-at-bunny jamie-at-bunny commented Jun 16, 2026

Copy link
Copy Markdown
Member

A user #96 on a 2012 Xeon (ThinkStation C30) hit Illegal instruction (core dumped) from both the installer and npm. Our binaries are compiled with Bun's default x64 target, which requires AVX2 — an instruction set that CPUs older than ~2013 (Sandy/Ivy Bridge) don't have. Same root cause as anthropics/claude-code#50684

macOS x64 baseline is intentional. Bun's docs say you "usually don't need" it on Darwin x64, but the linked claude-code issue was a pre-Haswell Intel Mac, so belt and braces.

@bogdan-at-bunny

Copy link
Copy Markdown

@codex review

@changeset-bot

changeset-bot Bot commented Jun 16, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 2b3f203

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 12 packages
Name Type
@bunny.net/cli Patch
@bunny.net/database-shell Patch
@bunny.net/cli-linux-x64 Patch
@bunny.net/cli-linux-arm64 Patch
@bunny.net/cli-darwin-x64 Patch
@bunny.net/cli-darwin-arm64 Patch
@bunny.net/cli-windows-x64 Patch
@bunny.net/database-shell-linux-x64 Patch
@bunny.net/database-shell-linux-arm64 Patch
@bunny.net/database-shell-darwin-x64 Patch
@bunny.net/database-shell-darwin-arm64 Patch
@bunny.net/database-shell-windows-x64 Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@greptile-apps

greptile-apps Bot commented Jun 16, 2026

Copy link
Copy Markdown

Greptile Summary

This PR ships non-AVX2 ("baseline") builds of both bunny and bsql for x64 CPUs that crash with Illegal instruction on the default Bun-compiled binary, fixing a reported issue on a 2012 Xeon. Both the shell installer and the npm CJS wrappers are updated.

  • install.sh gains a has_avx2() helper and selects bunny-linux/darwin-x64-baseline at download time; the CI workflow adds two new build jobs and attaches baseline binaries to GitHub Releases and to the x64 npm packages.
  • bunny.cjs and bsql.cjs now probe the CPU for AVX2 before spawning, putting the baseline binary first in the candidate list on non-AVX2 machines — eliminating the double-spawn cost on every invocation — and include a SIGILL-specific error message as a last-resort safety net.

Confidence Score: 5/5

Safe to merge — the change is purely additive, AVX2-capable machines take the existing fast path, and the detection logic defaults to assume AVX2 present on any error or unrecognized platform.

All code paths have explicit exits; the fallback is opt-in only when bunny-baseline / bsql-baseline exists alongside the primary binary; and detection errors are handled conservatively. The only finding is a minor inconsistency between substring matching in the .cjs files and word-boundary matching in the shell script.

No files require special attention.

Important Files Changed

Filename Overview
packages/cli/bin/bunny.cjs Adds proactive AVX2 detection and baseline-first candidate ordering; SIGILL fallback retained for edge cases. One minor substring-vs-word-boundary inconsistency with install.sh.
packages/database-shell/bin/bsql.cjs Identical logic to bunny.cjs — same AVX2 detection, same baseline-first ordering, same SIGILL message. Same minor substring-vs-word-boundary inconsistency.
.github/workflows/release.yml Two new build jobs (build-cli-baseline, build-database-shell-baseline) properly wired as dependencies of publish-cli and publish-database-shell; baseline binaries are copied into x64 npm packages and attached to GitHub Releases.
install.sh Adds has_avx2() with word-boundary grep; sets VARIANT=-baseline for x64 machines without AVX2; downloads the correct binary. chmod/codesign/xattr steps already act on the installed file regardless of variant.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[bunny / bsql invoked] --> B{process.arch === x64?}
    B -- No --> E[candidates = primary only]
    B -- Yes --> C{hasAvx2?}
    C -- Yes / error --> E
    C -- No --> D{baseline binary exists?}
    D -- No --> E
    D -- Yes --> F[candidates = baseline, primary]
    E --> G[candidates = primary, baseline?]
    G -->|baseline exists| H[candidates = primary, baseline]
    G -->|no baseline| I[candidates = primary only]
    F --> J[Spawn first candidate]
    H --> J
    I --> J
    J --> K{exit code?}
    K -- 0 --> L[process.exit 0]
    K -- non-zero --> M[process.exit status]
    K -- SIGILL + more candidates --> N[Spawn next candidate]
    N --> K
    K -- SIGILL + no more candidates --> O[Error: CPU not supported]
    K -- other signal/error --> P[Error: failed to execute]
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
    A[bunny / bsql invoked] --> B{process.arch === x64?}
    B -- No --> E[candidates = primary only]
    B -- Yes --> C{hasAvx2?}
    C -- Yes / error --> E
    C -- No --> D{baseline binary exists?}
    D -- No --> E
    D -- Yes --> F[candidates = baseline, primary]
    E --> G[candidates = primary, baseline?]
    G -->|baseline exists| H[candidates = primary, baseline]
    G -->|no baseline| I[candidates = primary only]
    F --> J[Spawn first candidate]
    H --> J
    I --> J
    J --> K{exit code?}
    K -- 0 --> L[process.exit 0]
    K -- non-zero --> M[process.exit status]
    K -- SIGILL + more candidates --> N[Spawn next candidate]
    N --> K
    K -- SIGILL + no more candidates --> O[Error: CPU not supported]
    K -- other signal/error --> P[Error: failed to execute]
Loading

Reviews (2): Last reviewed commit: "address comments" | Re-trigger Greptile

Comment thread packages/cli/bin/bunny.cjs
Comment thread packages/database-shell/bin/bsql.cjs
Comment thread packages/cli/bin/bunny.cjs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants